// router/index.ts

import { createRouter, createWebHashHistory} from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import webMain from '../components/webmain.vue';
import carousel from '../components/carousel.vue'
import img_card from '../components/img_card.vue'
import course_main from '../components/course_main.vue'
import renwuVue from '../components/renwu.vue'
import wenda from '../components/wenda.vue'
import common from '../components/common.vue'
import Login from '../components/Login.vue'
import index from '../components/index.vue'
import toupian from "../components/toupian.vue";
import shitu from "../components/shitu.vue";
import liebiaotu from "../components/liebiaotu.vue";

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'webMain',
        component: webMain
    },
    {
        path: '/course_main',
        name: 'course_main',
        component: course_main
    },
    {
        path: '/carousel',
        name: 'carousel',
        component: carousel
    },
    {
        path: '/img_card',
        name: 'img_card',
        component: img_card
    },
    {
        path:'/renwu',
        name:'renwu',
        component:renwuVue
    },
    {
        path:'/wenda',
        name:'wenda',
        component:wenda
    },
    {
      path:'/common',
      name:'common',
      component:common
    },
    {
        path:'/login',
        name:'Login',
        component:Login
    },
    {
        path:'/index',
        name:'inedx',
        component:index
    },
    {
        path:'/toupian',
        name:'toupian',
        component:toupian
    },{
        path:'/shitu',
        name:'shitu',
        component:shitu
    },{
        path:'/liebiaotu',
        name:'liebiaotu',
        component:liebiaotu
    }
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

// 添加导航守卫
// router.beforeEach((to, from, next) => {
//     // 检查是否需要认证
//     if (to.meta.requiresAuth) {
//         // 检查用户是否已认证
//         if (!useAuthStore().isAuthenticated) {
//             // 如果用户未认证，重定向到登录页面，并传递当前页面路径用于登录后跳转
//             next({ name: 'login', query: { redirect: to.fullPath } });
//         } else {
//             // 用户已认证，允许访问
//             next();
//         }
//     } else {
//         // 对于不需要认证的路由，直接允许访问
//         next();
//     }
// });

export default router;
